<?php
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$cab="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
  Header("Content-type: application/xml; charset=utf-8"); 
 echo $cab;
include ("admin\con_dbinterface.php");
		$sql="SELECT distinct tbte.co_exame,tbte.no_exame from historico.tb_bmh_tipo_exame  tbte
		ORDER BY no_exame";

		$res=pg_query($con,$sql);
		
		echo "<exames>";
			echo "<exame>";
				echo "<codigo>todos</codigo>";
				echo "<nome>Selecione o exame</nome>";	
				echo "</exame>";
				$aux='';
		while($linha=pg_fetch_array($res))
			{
			$exame=explode(',',$linha[1]);

			if($aux=='')
				{	
					$aux=$exame[0];
					$cod_aux=$linha[0];
				}
			else
				{

						if($aux!=$exame[0])
						{	
					/*		$cod_aux=$linha[0];
						}
					else
						{*/
						echo "<exame>";
						echo "<codigo>$cod_aux</codigo>";
						echo "<nome>$aux</nome>";	
						$aux=$exame[0];
						$cod_aux=$linha[0];
						echo "</exame>";
						}

				}	

			}
		echo "</exames>";
?>

		
